package ar.fiuba.tp7552.buildadmin.service;

import java.util.Collection;

import org.springframework.security.access.prepost.PreAuthorize;

import ar.fiuba.tp7552.buildadmin.model.BaseEntity;
import ar.fiuba.tp7552.buildadmin.model.BusinessException;
import ar.fiuba.tp7552.buildadmin.model.auth.User;

public interface UserService {
	
	@PreAuthorize("hasRole('ROLE_ADMIN')")
	public void createUser(User user) throws BusinessException;
	
	public User getUser(Long userId);
	
	@PreAuthorize("hasRole('ROLE_ADMIN') or #user.username == principal.name")
	public void update(User user);
	
	@PreAuthorize("hasRole('ROLE_ADMIN')")
	public void deleteUser(Long userId);
	
	@PreAuthorize("hasRole('ROLE_ADMIN')")
	public Collection<User> getAll();
	
	@PreAuthorize("hasRole('ROLE_ADMIN')")
	public void addPermission(User user, BaseEntity entity, PermissionType permission);
	
	@PreAuthorize("hasRole('ROLE_ADMIN')")
	public void delPermission(User user, BaseEntity entity, PermissionType permission);

}
